﻿using System;
using System.Collections.Generic;
using System.Web.UI;
using System.Text;
using System.IO;
using Lswweb.Domain;
using Lswweb.Model;

namespace Lswweb.Controls
{
    public class Utility
    {
        public static Control LoadSkinFile(System.Web.UI.Page page,string skinFileName)
        {
            if (string.IsNullOrEmpty(skinFileName))
                throw new Exception("未设置皮服文件.");

            string skinPath = Globals.GetSkinPath("/skins/" + skinFileName.TrimStart('/'));
            try
            {
                return page.LoadControl(skinPath);
            }
            catch(FileNotFoundException)
            {
                throw new Exception("错误:皮肤文件  " + skinPath + " 没有找到. 皮肤必须被指定,以用于控件的呈现.");
            }
        }
    }
}
